<?php
namespace app\mobile\controller;

use app\model\Record; 
use app\model\Util; 
use app\model\Theme; 
use app\model\Fans; 

class Getbasepdd extends Base
{
    public function Getbasepdd()
    {
global $_G, $_P;
$fans = $this->checkuser();

$system=$_G['system'];
$themeid = intval($_P['themeid']);
if($themeid < 0){
	return_msg('活动入口不正确');
}
$theme = Theme::getThemeById($themeid);
if(empty($theme['id'])){
    die(Util::showError("请确认活动地址是否正确"));
    return;
}
$config = 	Theme::getConfig($themeid);
if (empty($system['endday'])) {
	$endday = 5;
}else{
	$endday = $system['endday'];
}
$endday = $endday*24*3600;

if ($config['joinfee']=='0.00' && $config['groupprice']=='0.00'){
	if ($config['touxiang']==2) {
		$config['touxiang']=1;
	}
}
$themyrecordid = $_P['myid'];
$mytype = $_P['mytype'];
$nowgroupneednum = $_P['neednum'];
$friendlistuid = $_P['helpuid'];
if (!empty($_P['record'])) {
	$showrecord = Record::getAttendGroupById($_P['record']);;
}
	
	if ($system['ruanjian']==0 && $system['softstyle']==5) {
        $sql = "SELECT username,avatar,mobile,address,type,addtime FROM ".tablename(t_record)."
                        WHERE themeid =:themeid and status > 0 and uid > 0 order by id desc limit 5";
        $params = array();
        
        $params[':themeid'] = $themeid;
        $fanslist = db_select($sql,$params);

		foreach ($fanslist as $index => $row){
			if ($config['isshowname']==1 ){
				$usernamelen=mb_strlen($row['username'],'utf-8');
				if ($usernamelen > 2){
					$fanslist[$index]['username']=mb_substr($row['username'],0,1,'utf-8').'*'.mb_substr($row['username'],$usernamelen-1,1,'utf-8');
				}elseif (!empty($row['username'])){
					$fanslist[$index]['username']='*'.mb_substr($row['username'],-1,1,'utf-8');
				}
			}
			if ($row['type']==0){
				$fanslist[$index]['statustext']=$config['jmbiemingwenzi'];
			}else{
				$fanslist[$index]['statustext']=$config['jmbiemingwenzi2'];
			}
			$usernamelen=mb_strlen($row['mobile'],'utf-8');
			$fanslist[$index]['mobile']=mb_substr($row['mobile'],0,3,'utf-8').'****'.mb_substr($row['mobile'],$usernamelen-4,4,'utf-8');

			if (!empty($row['address'])) {
				$item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $row['address']);
				$shengshi = $item['areaName'];
				if (!empty($item)) {
					$item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $item['parentId']);
					$shengshi = $item['areaName'] . $shengshi;
				}
				if (!empty($item)) {
					$item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $item['parentId']);
					$shengshi = $item['areaName'] . $shengshi;
				}
				$fanslist[$index]['shengshi'] = $shengshi;
			}
        }


			$xunisql = "SELECT username,avatar FROM " . tablename('2019xuni_fans') . " where
				 id >0 limit 300";
			$xunilist = db_select ( $xunisql );
				foreach ($list as $index2 =>$row){
					$item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $row['parentId']);
					$list[$index2]['shiname'] = $item['areaName'];

					$item = db_find ( "SELECT * FROM " . tablename ( t_shengshi ) . " WHERE areaId= " . $item['parentId']);
					$list[$index2]['shengname'] = $item['areaName'];
					$shengshi = $list[$index2]['shengname'].$list[$index2]['shiname'].$row['areaName'];
					$data = array(
						'statustext'  => $config['jmbiemingwenzi'],
						'username'  => '线下加盟',
						'avatar'  => $xunilist[$index2]['avatar'],
						'address'  => '',
						'type'  => '',
						'addtime'  => '',
						'shengshi'  => $shengshi,
						);
					array_push($fanslist,$data);
				}
			
	    shuffle($fanslist);

	    //团数
	    // $groupsnum = Record::getFansNumByThemeId($themeid,$config['showalldata']);
	    // $groupsnum = intval($groupsnum)+intval($config['faketuan']);;
	    //浏览量
	    $scannum = Record::getscannumByThemeId($themeid,$config['showalldata'])+intval($config['fakescan']);


	}elseif ($system['ruanjian']==3 && $system['softstyle']==2) {


	    //团数
	    // $groupsnum = Record::getFansNumByThemeId($themeid,$config['showalldata']);
	    // $groupsnum = intval($groupsnum)+intval($config['faketuan']);;
	    //浏览量
	    $scannum = Record::getscannumByThemeId($themeid,$config['showalldata'])+intval($config['fakescan']);

	}else{
		//参加人数
		if ($system['softstyle']==6){
			$txnum = 42;
		}else{
			$txnum = 105;
		}
		if (!(($fans['status']==2 || ($theme['endtime']+$endday) < TIMESTAMP) && $system['s']['istouxiang']==1)) {
			if ($system['softstyle']==6){
				$fanslist = Record::getFanslistByThemeIdjm($themeid,$config['touxiang'],$txnum);
			}else{
				$fanslist = Record::getFanslistByThemeId($themeid,$config['touxiang'],$txnum,$config['showalldata']);
			}
		}else{
			$fanslist= array();
		}
		//虚拟头像
		if (count($fanslist)<$txnum && $config['fakejoin']>0){
			$tempcount = $txnum-count($fanslist);
			if ($tempcount > $config['fakejoin']){
				$tempcount = $config['fakejoin'];
			}
			if (strstr($config['softtag0'],"婚纱")!==false ){
				$kaishishu = intval( substr(MODULE_NAME, -1))%10*20+700;
			}else{
				$kaishishu = intval( substr(MODULE_NAME, -1))%10*50;
			}
			if ($config['touxiang']==0){
				$xunisql = "SELECT nickname as username,avatar FROM " . tablename('2019xuni_fans') . " where
				 id >". $kaishishu ." limit ".$tempcount;
			}else{
				$xunisql = "SELECT username,avatar FROM " . tablename('2019xuni_fans') . " where
				 id >". $kaishishu ." limit ".$tempcount;
			}
			$xunilist = db_select ( $xunisql );
			if ($system['softstyle']!=6){
				$fanslist = array_merge($fanslist , $xunilist);
			}
		}
		//隐藏客户真实姓名
		if ($config['touxiang']>0 && $config['isshowname']==1 ){
			foreach ($fanslist as $index => $row){
				$usernamelen=mb_strlen($row['username'],'utf-8');
				if ($usernamelen > 2){
					$fanslist[$index]['username']=mb_substr($row['username'],0,1,'utf-8').'*'.mb_substr($row['username'],$usernamelen-1,1,'utf-8');
				}elseif (!empty($row['username'])){
					$fanslist[$index]['username']='*'.mb_substr($row['username'],-1,1,'utf-8');
				}
	        }
		}

	    //团数
	    // if ($system['softstyle']==7 || $system['ruanjian']==1){
	    // 	$groupsnum =intval($theme['forward']);
	    // }else{
	    // 	$groupsnum = Record::getFansNumByThemeId($themeid,$config['showalldata']);
	    // }
	    // $groupsnum = intval($groupsnum)+intval($config['faketuan']);;
	    //浏览量
	    $scannum = Record::getscannumByThemeId($themeid,$config['showalldata'])+intval($config['fakescan']);

	}
    $groupsnum = Record::getFansNumByThemeId($themeid,$config['showalldata']);
    $groupsnum = intval($groupsnum)+intval($config['faketuan']);;
	// if ($config['iswxshare']==1) {
	// 	$groupsnum = intval(db_fetchcolumn ( 'SELECT COUNT(*) FROM ' . tablename ( t_fans ) . "
	// 			WHERE themeid = '{$row['id']}' " ));
	// 	$groupsnum = $groupsnum * 2 + intval($config['faketuan']);
	// }else{
	// 	$groupsnum = intval($theme['forward'])+intval($config['faketuan']);
	// }
		//获取头像
	if ($system['ruanjian']==1) {
		if ($config['iswttouxiang']==0){
			$headlist='';
			foreach ($fanslist as $index => $item) {
				$headlist = $headlist . "<li><img src='". tomedia($item['avatar']) ."'><em style=\"padding-right: 20px\">";
				if (empty($item['username'])){
					$headlist = $headlist . "null";
				}else{
					$headlist = $headlist . mb_substr($item['username'],0,3,'utf-8');
				}
				$headlist = $headlist . "</em></li>";
			}	
		}else{
			$headlist = "<div class=\"content user_head\">\n";
			foreach ($fanslist as $index => $item) {
				if ($index <= 13){
					$headlist .= "	<li>\n";
					$headlist .= "		<span class=\"new_head\"><img src=\"". tomedia($item['avatar']) ."\" alt=\"\"></span>\n<em>";
					if (empty($item['username'])){
						$headlist .= "null";
					}else{
						$headlist .= mb_substr($item['username'],0,3,'utf-8');
					}
					$headlist .= "</em></li>";
				}
			}
			$headlist .= "</div>\n";

			$headlist .= "<div class=\"content user_head\" style=\"padding-top: 0;\">\n";
			foreach ($fanslist as $index => $item) {
				if ($index > 13 && $index < 34){
					$headlist .= "<li>\n<span class=\"new_head\"><img src=\"". tomedia($item['avatar']) ."\" alt=\"\"></span>\n<em>";
					if (empty($item['username'])){
						$headlist .= "null";
					}else{
						$headlist .= mb_substr($item['username'],0,3,'utf-8');
					}
					$headlist .= "</em></li>";
				}
			}

			if ($index >= 34){
				$headlist .= "	<li class=\"last_head\">\n";
				$headlist .= "		...\n";
				$headlist .= "	</li>\n";
			}

			$headlist .= "</div>\n";

		}
	}elseif ($system['ruanjian']==3 && $system['softstyle']==2) {
		// $return_clicent = get_defined_vars();
return view('/lijianshangjia/index' , $return_clicent);
	}elseif ($system['ruanjian']==3 && $system['softstyle']==4) {
		// $return_clicent = get_defined_vars();
return view('/duoshangjia/index' , $return_clicent);
	}elseif ($system['ruanjian']==0 && $system['softstyle']==5) {
		// $return_clicent = get_defined_vars();
return view('/jiameng/index' , $return_clicent);
	}elseif ($system['ruanjian']==3 && $system['softstyle']==6) {
		// $return_clicent = get_defined_vars();
return view('/lijianduoshangjia/index' , $return_clicent);
	}elseif ($system['ruanjian']==0 && $system['softstyle']==8) {
		// $return_clicent = get_defined_vars();
return view('/game/index' , $return_clicent);
	}else{
		$headlist='';
		foreach ($fanslist as $index => $item) {
			$headlist = $headlist . "<li><img src='". tomedia($item['avatar']) ."'><br />";
			if (empty($item['username'])){
				$headlist = $headlist . "null";
			}else{
				$headlist = $headlist . mb_substr($item['username'],0,3,'utf-8');
			}
			$headlist = $headlist . "</li>";
		}	
	}
	$result['headlist'] = Theme::encode($headlist);


	if ($system['ruanjian']==1) {
		if ($config['iswttouxiang']==0){
			$scannumtxt = "<span style=\"color: #ffde00;\">&#21442;&#x4e0e;&nbsp;".$groupsnum."&nbsp;人</span>&nbsp;/&nbsp;浏览量：".$scannum."\n";
		}else{
			$scannumtxt = "<span>".$scannum."</span>人浏览";
		}
	}else{
		if ($system['softstyle']==7){
			$scannumtxt = "<span style='color: #ffde00;'>&#21442;&#x4e0e;&nbsp;".$groupsnum."&nbsp;人</span>&nbsp;/&nbsp;曝光&nbsp;".$scannum."&nbsp;次";
		}elseif ($system['softstyle']==1){
			$scannumtxt = "<i style=\"float: right; font-size: 16px; line-height: 18px; margin-top: -2px; text-align: left;\">&#21442;&#x4e0e;".$groupsnum."人&nbsp;&nbsp;";
			$scannumtxt .= "<br />";
			$scannumtxt .= "<b style=\"font-size: 12px; font-weight: normal;\">浏览量【{$scannum}】&nbsp;&nbsp;</b>";
			$scannumtxt .= "</i>";
		}else{
			$scannumtxt = "<span style='color: #ffde00;'>&#21442;&#x4e0e;&nbsp;".$groupsnum."&nbsp;人</span>&nbsp;/&nbsp;浏览量：".$scannum;
		}
	}
	$result['scannumtxt'] = Theme::encode($scannumtxt);



if ($system['friend'] == 1 || $config['isicon']==3) {

	$help_uid = $_P['help_uid'];
	if (!empty($friendlistuid)){
		$friendfans = Fans::getById($friendlistuid,$themeid);
		$params = array();
	    
	    $params[':uid'] = $_G['member']['uid'];
	    $params[':fromuid'] = $help_uid;
	    $params[':themeid'] = $themeid;
	    $friend = db_find("SELECT * FROM ".tablename(t_friend)."
			WHERE uid = :uid and themeid = :themeid and fromuid = :fromuid",$params);

		if(empty($friend)){
			$isfriend = 0;
		}else{
			$isfriend = 1;
		}
	}
}
if ($system['friend'] == 1) {


	if (!empty($friendlistuid)){
	    $params = array();
	    
	    $params[':fromuid'] = $friendlistuid;
	    $params[':themeid'] = $themeid;

		$friendlist = db_select("SELECT * FROM ".tablename(t_friend)."
	WHERE themeid = :themeid and fromuid = :fromuid",$params);
		$friendshengyu = $friendfans['friendnum']-$friendfans['friendshiyong'];

	}else{
		$friendshengyu = 0;
	}

		$sql = "SELECT * FROM " . tablename ( t_gift ) . " 
									WHERE giftgroupid = '{$config['friend_groupid']}' ORDER BY displayorder ";
		$friendlipinlist = db_select ( $sql );
	
		foreach ($friendlipinlist as $index => $item) {
			if ($friendshengyu>=$item['duihuan']){
				$friendlipinlist[$index]['jindu'] = 100;
			}else{
				$friendlipinlist[$index]['jindu'] = intval($friendshengyu/$item['duihuan']*100);
			}
			// if ($friendlistuid == $_G['member']['uid']){
				$params = array();
			    
			    $params[':uid'] = $friendlistuid;
			    $params[':giftid'] = $item['id'];
			    $params[':themeid'] = $themeid;
			    $isduihuan = db_find("SELECT * FROM ".tablename(t_exchange)."
					WHERE uid = :uid and themeid = :themeid and giftid = :giftid",$params);
			    if (!empty($isduihuan)){
					$friendlipinlist[$index]['isduihuan'] = 1;
				}
			// }

		}


	if (!empty($friendfans['username'])){
	  $friend .= "<div class=\"content star_personal\" >\n";
	  $friend .= "  <div class=\"content star_showhead\">\n";
	  $friend .= "   <img src=\"" . $friendfans['avatar'] . "\" class=\"star_headposition\">\n";
	  $friend .= "   <span><em>" . $friendfans['username'] . "</em>共收到<em>" . $friendfans['friendnum'] . "</em>" . str_replace("星星","<img src=http://css.yixuan.net/weike/images/weike04.png >",$config['friend_unit']) . "</span>\n";
	  $friend .= " </div>\n";
	  $friend .= "\n";
	  $friend .= "<div class=\"content\">\n";
	  $friend .= " <div class=\"content user_head\">\n";
	  foreach ($friendlist as $index => $item) {
	      if ( $index <= 13){
	        $friend .= "   <li>\n";
	        $friend .= "     <span class=\"new_head\"><img src=\"" .tomedia($item['avatar']) . "\" alt=\"\"></span>\n";
	        $friend .= "     <em>" .mb_substr($item['nickname'],0,4,'utf-8') . "</em>\n";
	        $friend .= "   </li>\n";
	      }
	  }
	  $friend .= " </div>\n";


	  if (count($friendlist) > 13){
	    $friend .= " <div class=\"content user_head\" style=\"padding-top: 0;\">\n";
	    foreach ($friendlist as $index => $item) {
	        $friend .= "   <li>\n";
	        $friend .= "     <span class=\"new_head\"><img src=\"" . $item['avatar'] . "\" alt=\"\"></span>\n";
	        $friend .= "     <em>" . mb_substr($item['nickname'],0,4,'utf-8') . "</em>\n";
	        $friend .= "   </li>\n";
	    }
	    $friend .= " </div>\n";
	  }
	  $friend .= "</div>\n";

	  if ( $friendlistuid == $_G['member']['uid']){
	      $help_uid = $_G['member']['uid'];
	      $friend .= " <div class=\"content\" style=\"text-align: center; font-size: 18px; color: #ff244e;\">\n";
	      $friend .= "   使用 " . $friendfans['friendshiyong'] . " " . $config['friend_unit'] . " | 剩余 " . $friendshengyu . " " . $config['friend_unit'];
	      $friend .= " </div>\n";
	      $friend .= "  <style type=\"text/css\">\n";
	      $friend .= " .tc_box{ background: url(https://css2019.yixuan.net/2019css/default/images/a111.png); width:90px; height: 80px; position: fixed; background-size:100% 100%; right: 5px; bottom: 65px; z-index: 999;}";
	      $friend .= " .tc_box p{ padding-top: 26px; text-align: center; font-size: 10px; color: '#1f143b;'}";
	      $friend .= " </style>\n";
	      $friend .= "  <a class=\"tc_box\" href=\"#friendhelp\"><p class=\"jlink\">已收集" . $friendfans['friendnum'] . "颗</p></a>\n";
	  }
	}
	// if (!empty($help_uid) && !empty($friendfans['username'])){
	//     $friend .= "<div class=\"content text_center star\" style=\"background: #ffffff;\" id=\"light\">\n";
	//     $friend .= " <div class=\"content star_wrap\" style=\"background: #ffffff;\">\n";
	//     $friend .= "   <ul class=\"content\" style=\"padding-top: 10px; margin-top: 10px; padding-bottom: 8px; background: none;\">\n";
	//     if ($isfriend == 0){
	//         if (empty($config['friend_wait'])){
	//           $friend .= "       <a class=\"new_light \" href=\"javascript:;\" onclick=\"dofriendhelp(" . $help_uid . ")\" ><span style=\"jlink\">" . $config['friend_anniu'] . "</span></a>\n";
	//         }else{
	//           $friend .= "       <input type=\"button\" class=\"new_light \" style=\" border: 0; color: #D9D9D9\" id=\"btnfriendhelp\" value=\"" . $config['friend_anniu'] . "(需等" . $config['friend_wait'] . "秒)\" onclick=\"dofriendhelp(" . $help_uid . ")\" disabled=\"disabled\" />\n";
	//         }
	//     }else{
	//         $friend .= "     <a class=\"new_light\" href=\"javascript:;\" >" . $config['friend_success'] . "</a>\n";
	//     }
	//     $friend .= "   </ul>\n";
	//     $friend .= " </div>\n";
	//     $friend .= "</div>\n";
	// }
	$result['friend'] = Theme::encode($friend);
	$friend = "";
	foreach ($friendlipinlist as $index => $item) {
	    $friend .= "   <dl class=\"content custom_price_list\" style=\"\n";
	    $friend .= "   background: ";
	    empty($config['starbgcolor'])?$friend .= "#62d4f5":$friend .= $config['starbgcolor'];
	    $friend .= ";\n";
	    $friend .= "   color: ";
	    empty($config['startextcolor'])?$friend .= "#ffffff":$friend .= $config['startextcolor'];
	    $friend .= ";\">\n";
	    if ($friendlistuid == $_G['member']['uid'] && $item['isduihuan']==0){
	      $friend .= "       <dt><p><a href=\"javascript:;\" onclick=\"showduihuan(" . $item['duihuan'] ."," . $item['id'] .")\" ><img  src=\"" .tomedia($item['giftimg2']) . "\" width=\"100%\" alt=\"\"></a>1</p></dt>\n";
	    }else{
	      $friend .= "       <dt><p><img src=\"" .tomedia($item['giftimg']) . "\" width=\"100%\" alt=\"\">2</p></dt>\n";
	    }
	    $friend .= "       <dd>\n";
	    $friend .= "         <div class=\"content jd_bg\">\n";
	    $friend .= "           <div class=\"content show_jd\" style=\"width:";
	    $item['isduihuan']==1?$friend .= "100":$friend .= $item['jindu'];
	    $friend .= "%;\"></div>\n";
	    $friend .= "         </div>\n";
	    $friend .= "         <div class=\"content jindu_text\">\n";
	    $friend .= "           <span style=\"text-align:left\">此奖品";
	    $item['isduihuan']==1?$friend .= "已用":$friend .= "需要";
	    $friend .= "<em>" . $item['duihuan'] . "</em>颗星星</span>\n";
	    $friend .= "           \n";
	    if ($item['isduihuan']==1){
	        $friend .= "               <span style=\"text-align:right\"><em>";
		    $friendlistuid == $_G['member']['uid']?$friend .= $friendfans['username']:$friend .= $friendfans['username'];
		    $friend .= "已兑换</em></span>\n";
	    }else{
	        $friend .= "               <span style=\"text-align:right\">";
		    $friendlistuid == $_G['member']['uid']?$friend .= "您":$friend .= $friendfans['username'];
		    $friend .= "已完成<em>" . $item['jindu'] . "%</em></span>\n";
	    }
	    $friend .= "         </div>\n";
	    $friend .= "       </dd>\n";
	    $friend .= "     </dl>\n";
	}


	if ($friendlistuid == $_G['member']['uid']){
	    $friend .= "<div class=\"popup-container giftinfo popup-hidden\" _v-20df1406=\"\">\n";
	    $friend .= " <div class=\"popup-mask\"></div>\n";
	    $friend .= " <div class=\"popup\">\n";
	    $friend .= "   <div class=\"popup-head\">\n";
	    $friend .= "           <h3 class=\"popup-title\" style=\"color: #fff;font-size: 16px;\" onclick=\"callphone()\">\n";
	    $friend .= "               <strong id=\"themedh\" style=\"color: #fff; font-weight: bold;font-size: 18px;\">解锁《假日礼盒》</strong>\n";
	    $friend .= "           </h3>\n";
	    $friend .= "   </div>\n";
	    $friend .= "       <div class=\"popup-center\">\n";
	    $friend .= "           <h3 id=\"giftinfotext\" class=\"popup-title\" style=\"color: #3E3C3C;font-size: 14px; padding-bottom: 10px\" >info \n";
	    $friend .= "           </h3>\n";
	    $friend .= "     <a href=\"javascript:dofriendexchange();\" ><img class=\"full-image\" style=\"text-align: center; width: 80%\" src=\"https://img2019.yixuan.net/images/2/2019/07/nDfr3WSw3wXgrVRKpw3w6VYXpXXwr6.png\" id=\"infoimg\"></a>\n";
	    $friend .= "       </div>\n";
	    $friend .= "   <div class=\"popup-body\">\n";
	    $friend .= "           <h4 class=\"popup-title\" id=\"\" style=\"text-align: center; \">\n";
	    $friend .= "               <strong class=\"balanced\" style=\"font-weight: bold;font-size: 10px; color: #b8b8b5\" >成功兑换后，请等待客服安排领取流程，谢谢参加！</strong>\n";
	    $friend .= "           </h4>\n";
	    $friend .= "   </div>\n";
	    $friend .= "    <input type=\"hidden\" id=\"giftid\" value=\"0\">\n";
	    $friend .= " </div>\n";
	    $friend .= "</div>\n";
	}
	$result['friend2'] = Theme::encode($friend);
}




//按扭文字

	$formtextpay = Theme::ButtonTextReplace($config['formtextpay'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
	if ($config['primeprice']!='0.00' ){
		$config['formtextleft']= str_replace("￥#dan#br", "", $config['formtextleft']);
	}
	if ($system['jiage'] > 0){ 
		$formtextpay = '立即支付';
		$formtextpay1 = Theme::ButtonTextReplace($config['formtextpay'],$config['joinfee'],0,0);
		$formtextpay2 = Theme::ButtonTextReplace($config['formtextpay'],$config['joinfee2'],0,0);
		$formtextpay3 = Theme::ButtonTextReplace($config['formtextpay'],$config['joinfee3'],0,0);
		$config['formtextcenter']= str_replace("￥#fee#br", "", $config['formtextcenter']);
		$config['formtextcenter2']= str_replace("￥#fee#br", "", $config['formtextcenter2']);
		$config['formtextcenternew']= str_replace("￥#fee#br", "", $config['formtextcenternew']);
		$config['formtextright']= str_replace("￥#fee#br", "", $config['formtextright']);
		$config['formtextleft']= str_replace("￥#fee#br", "", $config['formtextleft']);
		$config['isshowprice']=0;
	}
	 
	$formtextleft = Theme::ButtonTextReplace($config['formtextleft'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
	$formtextcenter = Theme::ButtonTextReplace($config['formtextcenter'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
	$formtextcenter= str_replace("<em>", "", $formtextcenter);
	$formtextcenter= str_replace("</em>", "", $formtextcenter);
	$formtextcenter2 = Theme::ButtonTextReplace($config['formtextcenter2'],$config['joinfee'],$config['primeprice'],$config['groupprice2']);
	$formtextcenternew = Theme::ButtonTextReplace($config['formtextcenternew'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
	$formtextright = Theme::ButtonTextReplace($config['formtextright'],$config['joinfee'],$config['primeprice'],$groupprice);

		$wtformtextpay = Theme::ButtonTextReplace($config['wtformtextpay'],$config['joinfee'],$config['primeprice'],$config['groupprice']);	
		$wtformtextleft = Theme::ButtonTextReplace($config['wtformtextleft'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
	if ($system['softstyle']==5) {
		$jmdibuwenzi = Theme::ButtonTextReplace($config['jmdibuwenzi'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
		$jmzhifuwenzi = Theme::ButtonTextReplace($config['jmzhifuwenzi'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
		$jmzhifuwenzi2 = Theme::ButtonTextReplace($config['jmzhifuwenzi2'],$config['joinfee'],$config['primeprice'],$config['groupprice']);
	}


$bottommenu ="";
if ($system['ruanjian']==1) {
	//微团模式菜单开始
	if ($config['wtisshowmenu']==1){
		$total1 = Record::getNumByThemeId($themeid,$config['touxiang'],$config['showalldata']);
	    $totalsum = $total1 + $config['fakejoin'];

		$bottommenu .= "   <div class=\"footer\">\n";
		$bottommenu .= "       <div class=\"info\">已报名" . $totalsum. "人</div>\n";
		if ( $config['joinfee']>0){
			if ( empty($themyrecordid)){
				$bottommenu .= "               <div class=\"buy\" onclick=\"showlogin(0)\">" . $wtformtextpay . "</div>\n";
			}else{
				if ( $config['ishexiao']==0){				
					$bottommenu .= "                   <a class=\"buy\" href=\"" . $_G['siteroot'] . createMobileUrl('mypay', array('themeid'=>$theme['id'])). "\" ><span style=\"color: #ffffff\">" . $config['wtlablesuccess'] ."</span>\n";
					$bottommenu .= "                   </a>\n";
				}else{
					$bottommenu .= "                   <a class=\"buy\" href=\"" . $_G['siteroot'] . createMobileUrl('myorder', array('themeid'=>$theme['id'])). "\" ><span style=\"color: #ffffff\">查看我的定单</span>\n";
					$bottommenu .= "                   </a>\n";
				}
			}
		}else{
			if ( empty($themyrecord['username'])){
				$bottommenu .= "               <div class=\"buy\" onclick=\"showloginfree(0)\">" . $wtformtextleft . "</div>\n";
			}else{
				$bottommenu .= "               <div class=\"buy\" >" . $config['wtlablesuccess'] . "</div>\n";
			}
		}
		$bottommenu .= "   </div>\n";
	}else{
		$bottommenu .= "   <div class=\"content double_12\" style=\" background:" . $config['formcolortop'] . "; z-index:100;\">\n";
		if ( $config['isicon']==1 && !empty($config['iconname_menu'])){
			$bottommenu .= "           <a  class=\"letgo\"  href='javascript:letgo();' >" .$config['iconname_menu'] . "</a>\n";
			$bottommenu .= "           <span>|</span>\n";
		}
		$bottommenu .= "    \n";
		if ( $config['joinfee']>0){
			if ( empty($themyrecordid)){
				$bottommenu .= "           <a href=\"javascript:;\" onclick=\"showlogin(0)\" style=\"color: " .$config['formcolorrighttext']. "\" >" .$wtformtextpay. "<img style=\"-webkit-animation: blink .75s linear infinite;\" src=\"https://css2019.yixuan.net/baom/xiaoshou.png\" width=\"26\" height=\"26\" alt=\"\"></a>\n";
			}else{
				$bottommenu .= "           <a  style=\"color: " .$config['formcolorrighttext']. "\" href=\"" . $_G['siteroot'] . createMobileUrl('mypay', array('themeid'=>$theme['id'])). "\" >" .$config['wtlablesuccess']. "</a>\n";
			}
		}else{
			if ( empty($themyrecord['username'])){
				$bottommenu .= "           <a href=\"javascript:;\" onclick=\"showloginfree(0)\"  style=\"color: " .$config['formcolorrighttext']. "\" >" .$wtformtextleft. "<img style=\"-webkit-animation: blink .75s linear infinite;\" src=\"https://css2019.yixuan.net/baom/xiaoshou.png\" width=\"26\" height=\"26\" alt=\"\"></a>\n";
			}else{
				$bottommenu .= "           <a  style=\"color: {$config['formcolorrighttext']}\" >" .$config['wtlablesuccess']. "</a>\n";
			}
		}
		$bottommenu .= "    </div>\n";
		$bottommenu .= "   </div>\n";
	}
	$result['bottommenu'] = Theme::encode($bottommenu);
}else{//拼团模式菜单开始

	if ($config['groupprice2']!='0.00' ){
		$bottommenu .= "<div id=\"bottommenu\" class=\"lv_newbottom menu02\" style=\"display: none;\">";
		$bottommenu .= "<a  href='javascript:;' onclick=\"showkfewm()\" >";
		$bottommenu .= "<img src=\"" . $_G['URL']['APP_IMAGE'] . "chat2.png\" alt=\"\"><br />";
		$bottommenu .= "客服";
		$bottommenu .= "</a>";
		$bottommenu .= "<a href=\"javascript:;\" onclick=\"swithmenu2()\">";
		$bottommenu .= "返回<br />上一级";
		$bottommenu .= "</a>";
		$bottommenu .= "<a href=\"javascript:;\" onclick=\"show_info(1)\">";
			if ($config['isshowprice']==2){ 
				$bottommenu .= "<em>￥</em>" . intval($config['groupprice']) . "<em>" . str_replace(intval($config['groupprice']).".",".",sprintf("%.2f",$config['groupprice'])) . "</em><br />";
			}
			$bottommenu .= $formtextcenter;
		$bottommenu .= "</a>";
		$bottommenu .= "<a href=\"javascript:;\" onclick=\"show_info(4)\">";
			if ($config['isshowprice']==2 ){
				$bottommenu .= "<em>￥</em>" . intval($config['groupprice2']) . "<em>" . str_replace(intval($config['groupprice2']).".",".",sprintf("%.2f",$config['groupprice2'])) . "</em><br />";
			}
			$bottommenu .= $formtextcenter2;
		$bottommenu .= "</a>";
		$bottommenu .= "</div>";
	}


	if ($config['isicon']==3) {
	$bottommenu .= "<div class=\"lv_newbottom menu01\" >";
	if ($friendlistuid == $_G['member']['uid']){
		if (empty($showrecord) ){
			$bottommenu .= "<a  href='javascript:;' onclick=\"showkfewm()\" style='line-height: 20px; width: 5%;' >";
			$bottommenu .= "<img src=\"" .$_G['URL']['APP_IMAGE'] . "chat2.png\" alt=\"\"><br />";
			$bottommenu .= "客服";
		}else{
			$bottommenu .= "<a onclick=\"letgo7()\" href='javascript:;' style='background:{$config['starbtcolor']};color:{$config['startextcolor']}' >邀请好友点亮";
		}
	}else{
		$bottommenu .= "<a  href='#light' style='background:{$config['starbtcolor']};color:{$config['startextcolor']}'>";
		if (!empty($friendlistuid)){
			if ($isfriend == 0){
				$bottommenu .= $config['iconname'];
			}else{
				$bottommenu .= $config['friend_success'];
			}
		}else{
			$bottommenu .= $config['iconname_menu'];
		}
	}
	$bottommenu .= "</a>";
	}else{
	$bottommenu .= "<div class=\"lv_newbottom menu01\" >";
	$bottommenu .= "<a  href='javascript:;' onclick=\"showkfewm()\" >";
	$bottommenu .= "<img src=\"" .$_G['URL']['APP_IMAGE'] . "chat2.png\" alt=\"\"><br />";
	$bottommenu .= "客服";
	$bottommenu .= "</a>";
	}
	if (empty($themyrecordid) ){
		if ($config['primeprice']!='0.00'  && $config['formtextleftopen']!=1){
			$bottommenu .= "<a href=\"javascript:;\" onclick=\"show_info(3)\">";
			if ($system['ruanjian']==0 && $system['softstyle']==1) {
				$bottommenu .= "团购价" . str_replace(".00","",$config['groupprice']) . "元<br/><em>单独购买" . str_replace(".00","",$config['primeprice']) . "元</em>";
			}else{
				if ($config['isshowprice']!=0 ){
						$bottommenu .= "<em>￥</em>" . intval($config['primeprice']) . "<em>" . str_replace(intval($config['primeprice']).".",".",sprintf("%.2f",$config['primeprice'])) . "</em><br />";
						$bottommenu .= "<em>" . str_replace("<br>","",$formtextleft) . "</em>";
				}else{
					$bottommenu .= $formtextleft;
				}
			}
			$bottommenu .= "</a>";
		}

		if (empty($showrecord) ){
			if ($config['groupprice2']!='0.00'){
				$bottommenu .= "<a href=\"javascript:;\" onclick=\"show_info(1)\">";
				if ($config['isshowprice']==2){
					$bottommenu .= "<em>￥</em>" . intval($config['groupprice']) . "<em>" . str_replace(intval($config['groupprice']).".",".",sprintf("%.2f",$config['groupprice'])) . "</em><br />";
				 }
				$bottommenu .= $formtextcenter;
				$bottommenu .= "</a>";
				$bottommenu .= "<a href=\"javascript:;\" onclick=\"show_info(4)\">";
				if ($config['isshowprice']==2){
					$bottommenu .= "<em>￥</em>" . intval($config['groupprice2']) . "<em>" . str_replace(intval($config['groupprice2']).".",".",sprintf("%.2f",$config['groupprice2'])) . "</em><br />";
				}
				$bottommenu .= $formtextcenter2 ;
				$bottommenu .= "</a>";
			}else{
				$bottommenu .= "<a href=\"javascript:;\" onclick=\"show_info(1)\">";
				if ($config['isshowprice']==2){
					$bottommenu .= "￥" . sprintf("%.2f",$config['groupprice']);
				}
				$bottommenu .= "" . str_replace("<br>","",$formtextcenter);
				$bottommenu .= "</a>";
			}
		}else{
			$bottommenu .= "<a href=\"javascript:;\" onclick=\"";
			if ($config['groupprice2']!='0.00'){
				$bottommenu .= "swithmenu()";
			}else{
				$bottommenu .= "show_info(1)";
			}
			$bottommenu .= "\">";

			if ($config['isshowprice']==2){
				$bottommenu .= "<em>￥</em>" . intval($config['groupprice']) . "<em>" . str_replace(intval($config['groupprice']).".",".",sprintf("%.2f",$config['groupprice'])) . "</em><br />";
			}
			$bottommenu .= $formtextcenternew;
			$bottommenu .= "</a>";
			$bottommenu .= "<a href=\"javascript:;\" onclick=\"show_info(2)\">";
			if ($config['isshowprice']==2){
				$bottommenu .= "<em>￥</em>" . intval($groupprice) . "<em>" . str_replace(intval($groupprice).".",".",sprintf("%.2f",$groupprice)) . "</em><br />";
			}
			$bottommenu .= $formtextright;
			$bottommenu .= "</a>";
		}
	}else{
		if ($config['joinfee']=='0.00' && $config['groupprice']=='0.00') {
			$bottommenu .= "<a href=\"javascript:;\" style=\"background:" . $config['formcolortop'] . "; line-height: normal;padding-top: 13px;\" >";
			$bottommenu .= "" . str_replace("组团", "报名", $config['lablesuccess']) . "";
			$bottommenu .= "</a>";
		}else{
			if ($config['ishexiao']==0 ){
				if ($mytype!=9){
					$bottommenu .= "<a href=\"javascript:;\"";
					$bottommenu .= "onclick=\"show_info(2)\"";
				}else{
					$url =   $_G['siteroot'].createMobileUrl('mypay',array("themeid"=>$themeid));
					$bottommenu .= "<a href=\"". $url . "\"";
				}
				if ($mytype!=9 ){
					$bottommenu .= "><em>团号:</em>" . $themyrecordid . "<br />";
					$bottommenu .= "<em>点击查看我的";
					if ($config['maxcountall']==1){
						$bottommenu .= "定单</em>";
					}else{
						$bottommenu .= "定单</em>";
					}
				}else{
					$bottommenu .= "><em>单买号:</em>" . $themyrecordid . "<br />";
					if ($config['showpayresult']==1){
						$bottommenu .= "<em>已单独购买</em>";
					}else{
						$bottommenu .= "<em>查看支付凭证</em>";
					}
				}
				$bottommenu .= "</a>";
			}else{
				$bottommenu .= "<a href=\"" . $_G['siteroot'] . createMobileUrl('myorder', array('themeid'=>$theme['id'])) . "\" >";
				$bottommenu .= "<em>定单号:</em>" . $themyrecordid . "<br />";
				$bottommenu .= "<em>点击查看我的定单</em>";
				$bottommenu .= "</a>";
			}
			if ($config['isicon']!==3){
				$bottommenu .= "<a href=\"javascript:letgo1();\" >";
				if ($mytype!=9 ){
					$bottommenu .= $config['lableleadergs'];
				}else{
					$bottommenu .= $config['lablegspy'];
				}
				$bottommenu .= "</a>";
			}
		}
	}
	$bottommenu .= "</div>";



	$result['bottommenu'] = Theme::encode($bottommenu);


	if ( $nowgroupneednum!=0 ) {
		$menutips = "此团仅剩" . $nowgroupneednum . "个名额";
		if ($refundtime > time()){
			$menutips .= ",倒计时:<em class=\"yamibox\" id=\"group_time\" data=\"" . date('Y-m-d H:i:s', $refundtime) . "\"></em>";
		}else{
			$menutips .= ", 您现在付款即可加入此团";
		}
	}else{
		if ( $config['maxcountall']>1 ) {
			if ( $config['tuanmode']==0 ) {
				$menutips = "此团已团成功";
			}else{
				$menutips = "此团已团成功,还可继续加入,共享福利";
			}
		}
	}
	$result['menutips'] = Theme::encode($menutips);

	$menutips2  = "<label style=\"";
	if (empty($showrecord) || $nowgroupneednum==0){
		$menutips2 .= "display: none;";
	}
	$menutips2 .= "\">";
	$menutips2 .= "<input type=\"radio\" name=\"check_type\" id=\"check_type_2\" value=\"2\" />";
	$menutips2 .= "<i>加入" . $showrecord['username'] . "的团<em>（此团仅剩" . $nowgroupneednum . "个名额）</em></i>";
	$menutips2 .= "</label>";

	if ( $config['primeprice']!='0.00'  && $config['formtextleftopen']!=1) {
		$menutips2 .= "<label>";
		$menutips2 .= "<input type=\"radio\" name=\"check_type\" id=\"check_type_3\" value=\"3\">";
		$menutips2 .= "<i>";
		if (empty($config['dandutips'])) {
			$menutips2 .= $formtextleft ."￥" .$config['primeprice'];
		}else{
			$menutips2 .= $config['dandutips'];
		}
		$menutips2 .= "</i></label>";
	}

	$menutips2 .= "<label>";
	$menutips2 .= "<input type=\"radio\" name=\"check_type\" id=\"check_type_1\" value=\"1\">";
	$menutips2 .= "<i>";
	if ( empty($config['pintuantips'])){
		$menutips2 .= "团购•" . $config['maxcountall'] . "人团购价￥" . $config['groupprice'];
	}else{
		$menutips2 .= $config['pintuantips'];
	}
	$menutips2 .= "</i></label>";


	if ( $config['groupprice2']!='0.00' ) {
		$menutips2 .= "<label>";
		$menutips2 .= "<input type=\"radio\" name=\"check_type\" id=\"check_type_4\" value=\"4\">";
		$menutips2 .= "<i>";
		if ( empty($config['pintuantips2'])){
			$menutips2 .= "团购•" . $config['maxcountall2'] . "人团购价￥" . $config['groupprice2'];
		}else{
			$menutips2 .= $config['pintuantips2'];
		}
		$menutips2 .= "</i></label>";
	}
	$result['menutips2'] = Theme::encode($menutips2);

	if ($config['joinfee']=='0.00'){
		$result['topay'] = Theme::encode("<strong>立即支付</strong>");
	}else{
		$result['topay'] = Theme::encode("<strong>" . $formtextpay . "</strong>");
	}

	$result['menutips2'] = Theme::encode($menutips2);

}//拼团模式菜单结束


$result['yiman'] = Theme::encode("此团已满");
$result['xintuan'] = Theme::encode("返回开一个新团");



$result['errcode'] = 0;
return_msg($result, '', 'ajax');

}
}